<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<%
	String path = request.getContextPath();
%>

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>appcode Request List</title>
		
		<script src="<%=path%>/static/js/jquery-1.6.1.min.js" type="text/javascript"></script>
		<script src="<spring:url value="/static/js/jquery.easyui.min.js" />" type="text/javascript" ></script>
		<link rel="stylesheet" type="text/css" href="<%=path%>/static/css/themes/default/easyui.css">
		<link href="<%=path%>/static/css/themes/icon.css" rel="stylesheet" type="text/css" />
		

	<script type="text/javascript">
	
			jQuery(function($){
				$('#appCodeRequestListTable').datagrid({
					title:'appCode Request List',
					method:'post',
					iconCls:'icon-edit',
					fit:true,
					fitColumns: true,
					striped: true,
					singleSelect: true,
					url:"appCodeRequestReportData",
					idField:'id',
					rownumbers:true,
					checkOnSelect:false,
					columns:[[
						{field:'createTime',title:'日期',width:8},
						{field:'province',title:'省份',width:8},
						{field:'provider',title:'运营商',width:8},
						{field:'addUser',title:'游戏名称',width:8},
						{field:'activeUser',title:'CP名称',width:8},
						{field:'totalUser',title:'渠道名称',width:7},
						{field:'totalUser',title:'总请求量',width:7},
						{field:'totalUser',title:'总成功请求量',width:7}
					]],
					onLoadSuccess:function(data){
						$('#appCodeRequestListTable').datagrid('clearSelections');
						$('#appCodeRequestListTable').datagrid('clearChecked');
					}
				});
		    });
			
        	$.ajaxSetup({
					global : false,
					type : "POST",
					complete : function(XMLHttpRequest, textStatus) {
						var data = XMLHttpRequest.responseText;
						var redirect=window.top.location.host+"/YouLeCloud/login";
						if (data=="timeout") {
							if (window.top != window.self) {
							   window.top.location.href="${redirect}";
							   return;
							   }
						}
					}
				});

        	
            var height = window.screen.height-250;  
            var width = window.screen.width;  
            var leftW = 300;  
            if(width>1200){  
               leftW = 400;  
            }else if(width>1000){  
               leftW = 350;
            }else {  
               leftW = 100;
            }
        	
			function reloadDataGrid() {
				var params = $('#appCodeRequestListTable').datagrid('options').queryParams;
				var fields =$('#queryForm').serializeArray();
				$.each( fields, function(i, field){
					params[field.name] = field.value;
				});
				$('#appCodeRequestListTable').datagrid('reload');
			}
			
			function searchInfo() {
		    	var startDate = $('#startDate').datebox('getValue');
		    	var endDate = $('#endDate').datebox('getValue');
		    	if(startDate != '' && endDate != '') {
		    		if (Date.parse(startDate) > Date.parse(endDate)) {
		    			alert("开始时间不能大于结束时间");
		    			return;
		    		}
		    	}
				reloadDataGrid();
			}
			
		    function dateformatter(date){
		        var y = date.getFullYear();
		        var m = date.getMonth()+1;
		        var d = date.getDate();
		        return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
		    }
	</script>
		
	</head>


	<body class="easyui-layout" style="height: 100%">
	
		<div data-options="region:'north'" 
			style="padding: 1px 0 1px 1px; height: 80px;"
			title="Search">
			<form id="queryForm" style="margin:5;text-align: center;">
			<table width="100%">
				<tr>
					<td>
						<span style="font-size: 14px">开始日期：</span>&nbsp;
						<input class="easyui-datebox" data-options="formatter:dateformatter" id="startDate" name="startDate" style="width: 150">&nbsp;
					</td>
					<td>
						<span style="font-size: 14px">结束日期：</span>&nbsp;
						<input class="easyui-datebox" data-options="formatter:dateformatter" id="endDate" name="endDate" style="width: 150">&nbsp;
					</td>

					<td>
						运营商 &nbsp;&nbsp;&nbsp;&nbsp;<input class="easyui-combobox" 
							name="provider"
							data-options="
									url:'<%=path%>/spcodepercent/spCodePercentproviderIDListAll',
									method:'get',
									valueField:'name',
									textField:'name',
									hasDownArrow :true,
									panelHeight:'auto'
							">
					</td>
					<td>
						省份 &nbsp;&nbsp;&nbsp;&nbsp;<input class="easyui-combobox" 
							name="province"
							data-options="
									url:'<%=path%>/spcodepercent/spCodePercentprovinceCodeListAll',
									method:'get',
									valueField:'name',
									textField:'name',
									hasDownArrow :true,
									panelHeight:'200'
							">
					</td>
					<td>
						<a href="#" onclick="searchInfo();" class="easyui-linkbutton" iconCls="icon-search"><div style="width: 30px;float: left;">查询</div></a>
					</td>
				</tr>
			</table>
			</form>
		</div>
	
		<div data-options="region:'center'" style="padding:10; " id="tabdiv">
			<table id="appCodeRequestListTable"></table>
		</div>
		
	</body>
